package cn.com.anysdk.redis.exception;

/**
 * Redis环境异常
 */
public class RedisEnvironmentException extends RedisException {
    
    private static final String ERROR_CODE_PREFIX = "REDIS_ENV_";
    
    public RedisEnvironmentException(String message) {
        super(message, ERROR_CODE_PREFIX + "ERROR");
    }
    
    public RedisEnvironmentException(String message, String errorCode) {
        super(message, ERROR_CODE_PREFIX + errorCode);
    }
    
    public RedisEnvironmentException(String message, Throwable cause) {
        super(message, cause, ERROR_CODE_PREFIX + "ERROR");
    }
    
    public RedisEnvironmentException(String message, Throwable cause, String errorCode) {
        super(message, cause, ERROR_CODE_PREFIX + errorCode);
    }
    
    /**
     * 配置缺失异常
     */
    public static class ConfigMissingException extends RedisEnvironmentException {
        public ConfigMissingException(String message) {
            super(message, "CONFIG_MISSING");
        }
        
        public ConfigMissingException(String message, Throwable cause) {
            super(message, cause, "CONFIG_MISSING");
        }
    }
    
    /**
     * 环境未定义异常
     */
    public static class UndefinedEnvironmentException extends RedisEnvironmentException {
        public UndefinedEnvironmentException(String message) {
            super(message, "UNDEFINED");
        }
        
        public UndefinedEnvironmentException(String message, Throwable cause) {
            super(message, cause, "UNDEFINED");
        }
    }
    
    /**
     * 环境切换异常
     */
    public static class SwitchException extends RedisEnvironmentException {
        public SwitchException(String message) {
            super(message, "SWITCH");
        }
        
        public SwitchException(String message, Throwable cause) {
            super(message, cause, "SWITCH");
        }
    }
}